tab = readtable('uk_graph2-1_resid2.csv');
tab = table2array(tab);

figure('position', [0, 0, 800, 500])
tiledlayout(2,1,'TileSpacing','Compact','Padding','Compact');

nexttile

yyaxis left
plot(tab(:,1), tab(:,11),'LineWidth',1.2);
ylim([10, 41]);

yyaxis right
plot(tab(:,1), tab(:,9),'LineWidth',1.2);
ylim([-0.03, 0.06]);
hold on

bands2 = [1937.25, 1938.25; 1945, 1945.75; 1948.75, 1949.75; 1953.25, 1954.25; 1957.5, 1958.25; 1960.25, 1961; ...
            1969.75, 1970.75; 1973.75, 1975; 1980, 1980.5; 1981.5, 1982.75; 1990.5, 1991; 2001, 2001.75; ...
            2007.75, 2009.25];

xp = [bands2 fliplr(bands2)];
yp = ([[1;1]*min(ylim); [1;1]*max(ylim)]*ones(1,size(bands2,1))).';
for k = 1:size(bands2,1)                                                             
    patch(xp(k,:), yp(k,:), [0.8500 0.3250 0.0980], 'FaceAlpha', 0.2, 'LineStyle', 'none')
end

ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'k';

xlim([1935 2020]);
xlabel('Date');
legend('US volatility (left)', 'UK volatility (right)')
title('a) US volatility and UK Volatility')

nexttile

tab = readtable('fed_gdp.csv');
tab = table2array(tab);

yyaxis left
plot(tab(:,1), tab(:,3),'LineWidth',1.2);
ylim([0.14, 0.255]);

yyaxis right
plot(tab(:,1), tab(:,2),'LineWidth',1.2);
ylim([-0.03, 0.06]);
hold on

bands2 = [1937.25, 1938.25; 1945, 1945.75; 1948.75, 1949.75; 1953.25, 1954.25; 1957.5, 1958.25; 1960.25, 1961; ...
            1969.75, 1970.75; 1973.75, 1975; 1980, 1980.5; 1981.5, 1982.75; 1990.5, 1991; 2001, 2001.75; ...
            2007.75, 2009.25];

xp = [bands2 fliplr(bands2)];
yp = ([[1;1]*min(ylim); [1;1]*max(ylim)]*ones(1,size(bands2,1))).';
for k = 1:size(bands2,1)                                                             
    patch(xp(k,:), yp(k,:), [0.8500 0.3250 0.0980], 'FaceAlpha', 0.2, 'LineStyle', 'none')
end

ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'k';

xlim([1947 2020]);
xlabel('Date');
legend('US Gov. spending-to-GDP (left)', 'UK volatility (right)')
title('b) Gov. spending-to-GDP and UK Volatility')

